package server;

import java.net.InetAddress;

import lp.polimi.treefinder.utils.ManagingMessage;

/**
 * Core of the server. 
 */
public interface SingleProtocol {

	/**
	 * Open a socket and start listening.
	 */
	public void initialize ();
	
	/**
	 * Report session information.
	 */
	public void writeInfo();

	/** Closes the connections of all the users currently connected to the server.
	 */
	public void closeSockets();
	
	public InetAddress getAddress();
	
	public int getPort();

	/** Send a message to the client
	 * 
	 * @param managingMessage The message.
	 * @param address IP address of the client.
	 */
	public void send(ManagingMessage managingMessage, Object address) throws Exception;

	/** Closes the connection to a client.
	 * @param address IP address of the client.
	 */
	public void closeSocket(Object address);

	/** Open a connection upon client request.
	 * @return A socket.
	 */
	public GenericSocket acceptConnection() throws Exception;
	
}